package com.benew.ntt.evaluate.constant

import android.os.Environment
import com.benew.ntt.evaluate.sdk.EvalSDKConfig
import com.benew.ntt.evaluate.sdk.EvalSDKDevice

object EvalConst {
    /**
     * 录音文件路径
     */
    private val RECORD_FILE_PATH_R2 =
        Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).absolutePath +
                "/EvalRecord"

    /**
     * 录音文件路径
     */
    private val RECORD_FILE_PATH_OLED =
        Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).absolutePath +
                "/EvalRecord"

    /**
     * 分数难易度分数配置R2
     */
    private val SCORE_FILE_PATH_R2 =
        Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOCUMENTS).absolutePath +
                "/com.ntt.core.service/eval/level"

    /**
     * 分数难易度分数配置
     */
    private val SCORE_FILE_PATH_OLED =
        Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOCUMENTS).absolutePath +
                "/com.ntt.core.service/eval/level"

    /**
     * 分数难易度等级配置
     */
    private val LEVEL_FILE_PATH_R2 =
        Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOCUMENTS).absolutePath +
                "/com.benew.nttr2.settings/evaluate/voice_evaluate"

    /**
     * 分数难易度等级配置
     */
    private val LEVEL_FILE_PATH_OLED =
        Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOCUMENTS).absolutePath +
                "/com.benew.nttr2.settings/evaluate/voice_evaluate"


    var config: EvalSDKConfig? = null

    /**
     * 获取录音位置
     */
    fun getRecordFilePath(): String {
        return if (!config?.recordFilePath.isNullOrBlank()) {
            config?.recordFilePath!!
        } else {
            return if (config?.getDeviceType() == EvalSDKDevice.OLED) {
                RECORD_FILE_PATH_OLED
            } else {
                RECORD_FILE_PATH_R2
            }
        }
    }

    /**
     * 分数难易度分数配置位置
     */
    fun getScoreFilePath(): String {
        return if (!config?.scoreFilePath.isNullOrBlank()) {
            config?.scoreFilePath!!
        } else {
            return if (config?.getDeviceType() == EvalSDKDevice.OLED) {
                SCORE_FILE_PATH_OLED
            } else {
                SCORE_FILE_PATH_R2
            }
        }
    }

    /**
     * 分数难易度等级配置位置
     */
    fun getLevelFilePath(): String {
        return if (!config?.levelFilePath.isNullOrBlank()) {
            config?.levelFilePath!!
        } else {
            return if (config?.getDeviceType() == EvalSDKDevice.OLED) {
                LEVEL_FILE_PATH_OLED
            } else {
                LEVEL_FILE_PATH_R2
            }
        }
    }

    /**
     * WarrantId过期前N小时重新获取
     */
    fun getWarrantIdTime(): Long {
        return config?.warrantIdTime ?: 6 * 60 * 60 * 1000L
    }
}